<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
  <style>
    * {
      margin: 0;
      padding: 0;
    }
    .main {
      width: 100px;
      height: 100px;
      background-color: aquamarine;
    }
  </style>
</head>
<body>
  <div class="main"></div>

  <script>
    // Shift + 鼠标左键拖动
    window.visualViewport.addEventListener('resize', function(event) {
      console.log(window.visualViewport, '视觉视口大小发生变化时触发')
    })
    console.log(window.visualViewport, '视觉视口大小发生变化时触发')
  </script>
</body>
</html>
